//微信认证服务器
// const https = require('https');
// const url = require('url');
// const querystring = require('querystring');
// const crypto = require('crypto');
// const TOKEN = 'whatever';   // token可以是任何字符串，前提是必须和上图基础配置的一致
// https.createServer((req, res) => {
//     if (/\*\/\*/img.test(req.headers.accept)) {
//     const _query = url.parse(req.url).query;
//     const query = querystring.parse(_query);
//     const signature = query.signature;
//     const echostr = query.echostr;
//     const timestamp = query.timestamp;
//     const nonce = query.nonce;
//     // 拼成数组，字典排序，再拼接
//     const tmpStr = [TOKEN, timestamp, nonce].sort().reduce((prev, cur) => prev + cur);
//     // sha1加密
//     const sha1 = crypto.createHash('sha1');
//     const sha1_result = sha1.update(tmpStr).digest('hex');
//     // 如果是来自微信的请求就返回echostr
//     if (sha1_result === signature) {
//         res.end(echostr);
//     }
// }
// }).listen(443, () => {
//     console.log(`server start at 443`);   // 一定要是443端口
// });
const express = require("express");
const path=require('path');
const app = express();
server  = require('http').Server(app);
app.set('views',__dirname);    // 设置视图
app.set('view engine', 'html');
app.engine( '.html', require( 'ejs' ).__express );
require('./index')(app);      //路由配置文件
server.listen(8080,function(){
    console.log('server start,port 8080');
});